using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mvc.Mailer;
using System.Net.Mail;
using FloodFree.Common;
using System.Web.Security;

namespace FloodFree.Web.Mailers
{ 
    public class UserMailer : MailerBase, IUserMailer     
	{
        FloodFreeContext db;
		public UserMailer():
			base()
		{
            db = new FloodFreeContext();
			MasterName="_Layout";
		}


        public virtual MailMessage Welcome(String username)
		{
			var mailMessage = new MailMessage{Subject = "Welcome"};
			
			//mailMessage.To.Add("some-email@example.com");
			//ViewBag.Data = someObject;
			PopulateBody(mailMessage, viewName: "Welcome");

			return mailMessage;
		}


        public virtual MailMessage SubscribedArea(String username, int sensorId)
		{
            MembershipUser user = Membership.GetUser(username);
			var mailMessage = new MailMessage{Subject = "SubscribedArea"};
            mailMessage.To.Add(user.Email);
			PopulateBody(mailMessage, viewName: "SubscribedArea");
			return mailMessage;
		}


        public virtual MailMessage FloodedArea(String username, int sensorId)
		{
            MembershipUser user = Membership.GetUser(username);

			var mailMessage = new MailMessage{Subject = "FloodedArea"};
            mailMessage.To.Add(user.Email);
			PopulateBody(mailMessage, viewName: "FloodedArea");

			return mailMessage;
		}


        public virtual MailMessage UnfloodedArea(String username, int sensorId)
		{
            MembershipUser user = Membership.GetUser(username);

			var mailMessage = new MailMessage{Subject = "UnfloodedArea"};
            mailMessage.To.Add(user.Email);
			PopulateBody(mailMessage, viewName: "UnfloodedArea");

			return mailMessage;
		}

		
	}
}